package secondBrush.hash;

import java.util.Arrays;
import java.util.HashMap;

public class E01Leetcode242 {
    public static boolean isAnagram(String s, String t) {
        int length = s.length();
        char[] arrS = new char[length];
        for (char i = 0; i < length; i++) {
            arrS[i] = s.charAt(i);
        }
        Arrays.sort(arrS);
        int length1 = t.length();
        if (length1 != length) {
            return false;
        }
        char[] arrT = new char[length1];
        for (char i = 0; i < length1; i++) {
            arrT[i] = t.charAt(i);
        }
        Arrays.sort(arrT);

        for (char i = 0; i < length; i++) {
            if (arrS[i] != arrT[i]) {
                return false;
            }
        }

        return true;
    }

    public static boolean isAnagram2(String s, String t) {
        int lengthS = s.length();
        int lengthT = t.length();

        char[] charArrayS = s.toCharArray();
        char[] charArrayT = t.toCharArray();

        Arrays.sort(charArrayS);
        Arrays.sort(charArrayT);


        return true;

    }

    public static boolean isAnagram3(String s, String t) {


        return true;
    }

    public int[] getAnagram(String s) {
        int length = s.length();
        int[] arr = new int[26];
        for (int i = 0; i < length; i++) {
            char c = s.charAt(i);
            arr[c - 'a']++;
        }
        return arr;
    }



    public static void main(String[] args) {
        System.out.println(isAnagram("anagram", "nagaram"));

    }

}
